<html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms"
	xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns="http://www.w3.org/1999/xhtml" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
	xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:widget="http://orbeon.org/oxf/xml/widget"
	xmlns:xi="http://www.w3.org/2001/XInclude">
	<head>
		<title>Numishare: Edit Numismatic Collection Information</title>
		<link type="text/css" href="http://localhost:8080/cocoon/numishare/xforms.css"
			rel="stylesheet"/>
		<xforms:model>
			<!-- main instance -->
			<xforms:instance id="eadheader" xmlns="">
				<eadheader>
					<eadid/>
					<filedesc>
						<titlestmt>
							<titleproper/>
						</titlestmt>
						<publicationstmt>
							<publisher/>
						</publicationstmt>
					</filedesc>
				</eadheader>
			</xforms:instance>

			<xforms:instance id="archdesc_did" xmlns="">
				<archdesc level="collection">
					<did>
						<unittitle/>
					</did>
				</archdesc>
			</xforms:instance>

			<xforms:instance id="status">
				<selected/>
			</xforms:instance>

			<!-- eadheader -->
			<xforms:instance id="profiledesc-template">
				<profiledesc xmlns=""/>
			</xforms:instance>
			<xforms:instance id="revisiondesc-template">
				<revisiondesc xmlns=""/>
			</xforms:instance>
			<xforms:instance id="editionstmt-template">
				<editionstmt xmlns="">
					<edition/>
				</editionstmt>
			</xforms:instance>
			<xforms:instance id="notestmt-template">
				<notestmt xmlns=""/>
			</xforms:instance>
			<xforms:instance id="publicationstmt-template">
				<publicationstmt xmlns=""/>
			</xforms:instance>
			<xforms:instance id="seriesstmt-template">
				<seriesstmt xmlns=""/>
			</xforms:instance>

			<!-- shared -->
			<xforms:instance id="author-template">
				<author xmlns=""/>
			</xforms:instance>
			<xforms:instance id="creation-template">
				<creation xmlns=""/>
			</xforms:instance>
			<xforms:instance id="change-template">
				<change xmlns="">
					<date/>
					<item/>
				</change>
			</xforms:instance>
			<xforms:instance id="date-template">
				<date xmlns=""/>
			</xforms:instance>
			<xforms:instance id="descrules-template">
				<descrules xmlns=""/>
			</xforms:instance>
			<xforms:instance id="langusage-template">
				<langusage xmlns=""/>
			</xforms:instance>
			<xforms:instance id="num-template">
				<num type="" xmlns=""/>
			</xforms:instance>
			<xforms:instance id="publisher-template">
				<publisher xmlns=""/>
			</xforms:instance>
			<xforms:instance id="sponsor-template">
				<sponsor xmlns=""/>
			</xforms:instance>
			<xforms:instance id="subtitle-template">
				<subtitle xmlns=""/>
			</xforms:instance>
			<xforms:instance id="titleproper-template">
				<titleproper xmlns=""/>
			</xforms:instance>

			<!-- generic instances -->
			<xforms:instance id="address-template">
				<address xmlns=""/>
			</xforms:instance>
			<xforms:instance id="addressline-template">
				<addressline xmlns=""/>
			</xforms:instance>
			<xforms:instance id="blockquote-template">
				<blockquote xmlns=""/>
			</xforms:instance>
			<xforms:instance id="head-template">
				<head xmlns=""/>
			</xforms:instance>
			<xforms:instance id="language-template">
				<language langcode="" xmlns=""/>
			</xforms:instance>
			<xforms:instance id="note-template">
				<note xmlns=""/>
			</xforms:instance>
			<xforms:instance id="p-template">
				<p xmlns=""/>
			</xforms:instance>
			
			<!-- did elements -->
			<xforms:instance id="abstract-template">
				<abstract xmlns=""/>
			</xforms:instance>
			<xforms:instance id="container-template">
				<container type="" xmlns=""/>
			</xforms:instance>
			<xforms:instance id="langmaterial-template">
				<langmaterial xmlns="">
					<language langcode=""/>
				</langmaterial>
			</xforms:instance>
			<xforms:instance id="materialspec-template">
				<materialspec xmlns=""/>
			</xforms:instance>
			<xforms:instance id="origination-template">
				<origination xmlns=""/>
			</xforms:instance>
			<xforms:instance id="physdesc-template">
				<physdesc xmlns=""/>
			</xforms:instance>
			<xforms:instance id="physfacet-template">
				<physfacet type="" xmlns=""/>
			</xforms:instance>
			<xforms:instance id="dimensions-template">
				<dimensions xmlns=""/>
			</xforms:instance>
			<xforms:instance id="extent-template">
				<extent xmlns=""/>
			</xforms:instance>
			<xforms:instance id="physloc-template">
				<physloc xmlns=""/>
			</xforms:instance>
			<xforms:instance id="repository-template">
				<repository xmlns=""/>
			</xforms:instance>
			<xforms:instance id="unitdate-template">
				<unitdate normal="" xmlns=""/>
			</xforms:instance>
			<xforms:instance id="unitid-template">
				<unitid xmlns=""/>
			</xforms:instance>
			
			<!-- languages -->
			<xforms:instance id="languageselect-template" src="/apps/numishare/instances/languages.xml"/>

			<xforms:bind nodeset="instance('eadheader')">
				<xforms:bind nodeset="eadid" required="true()">
					<xforms:bind nodeset="@mainagencycode" required="true()"/>
				</xforms:bind>
				<xforms:bind nodeset="filedesc">
					<xforms:bind nodeset="titlestmt/titleproper" required="true()"/>
					<xforms:bind nodeset="publicationstmt/publisher" required="true()"/>
				</xforms:bind>

			</xforms:bind>

			<xforms:bind nodeset="instance('archdesc_did')/did">
				<xforms:bind nodeset="unittitle" required="true()"/>
			</xforms:bind>

			<!-- Load EAD Header -->
			<xforms:submission id="load-eadheader" serialization="none" method="get"
				action="/exist/rest/db/numishare/pieces/eadheader.xml" xxforms:username="admin"
				xxforms:password="admin" replace="instance" instance="eadheader">
				<xforms:message ev:event="xforms-submit-error" level="modal">EAD Header Load
					Error!</xforms:message>
			</xforms:submission> 

			<!-- Save EAD Header -->
			<xforms:submission id="save-eadheader" ref="instance('eadheader')"
				xxforms:username="admin" xxforms:password="admin"
				action="/exist/rest/db/numishare/pieces/eadheader.xml" method="put" replace="none">
				<xforms:message ev:event="xforms-submit-error" level="modal">EAD Header Save
					Error!</xforms:message>
			</xforms:submission>

			<!-- Load Archdesc Descriptive Identification -->
			<xforms:submission id="load-archdesc" serialization="none" method="get"
				action="/exist/rest/db/numishare/pieces/archdesc_did.xml" xxforms:username="admin"
				xxforms:password="admin" replace="instance" instance="archdesc_did">
				<xforms:message ev:event="xforms-submit-error" level="modal">Archdesc/did Load
					Error!</xforms:message>
			</xforms:submission>

			<!-- Save Archdesc Descriptive Identification -->
			<xforms:submission id="save-archdesc" ref="instance('archdesc_did')"
				xxforms:username="admin" xxforms:password="admin"
				action="/exist/rest/db/numishare/pieces/archdesc_did.xml" method="put"
				replace="none">
				<xforms:message ev:event="xforms-submit-error" level="modal">Archdesc/did Save
					Error!</xforms:message>
			</xforms:submission>

			<!-- load form on page load -->
			<xforms:send ev:event="xforms-model-construct-done" submission="load-eadheader"/>
			<xforms:send ev:event="xforms-model-construct-done" submission="load-archdesc"/>
		</xforms:model>
	</head>
	<body>
		<div class="form">
			<xforms:group ref="instance('status')/text()">
				<div class="success">
					<xforms:output ref="instance('status')"/>
				</div>
			</xforms:group>
			<div class="submission">
				<xforms:trigger appearance="minimal">
					<xforms:label class="file_control"><img
						src="/apps/numishare/images/save.gif" alt="Save"/>
						Save</xforms:label>
					<xforms:action ev:event="DOMActivate">
						<xforms:send submission="save-eadheader"/>
						<xforms:send submission="save-archdesc"/>
						<xforms:setvalue ref="instance('status')" ev:event="xforms-submit-done">Collection metadata saved.</xforms:setvalue>
					</xforms:action>
				</xforms:trigger>
				
				<xforms:trigger appearance="minimal">
					<xforms:label class="file_control"><img
						src="/apps/numishare/images/recycle-green.png" alt="Load"/>
						Load</xforms:label>
					<xforms:action ev:event="DOMActivate">
						<xforms:send submission="load-eadheader"/>
						<xforms:send submission="load-archdesc"/>
						<xforms:setvalue ref="instance('status')" ev:event="xforms-submit-done">Collection metadata reloaded.</xforms:setvalue>
					</xforms:action>
				</xforms:trigger>

			</div>
			<widget:tabs>
				<!--**************************************** EAD HEADER **********************************-->
				<widget:tab id="eadheader-tab">
					<widget:label>EAD Header</widget:label>
					<xforms:group ref="instance('eadheader')">
						<h2>EAD Header</h2>
						<p>Fields in this tab record metadata about the EAD XML file itself.</p>
						<xforms:group ref=".[count(//profiledesc) &lt; 1]">
							<xforms:trigger appearance="minimal">
								<xforms:label>
									<img src="/apps/numishare/images/add.gif"/>Profile
									Description</xforms:label>
								<xforms:insert ev:event="DOMActivate" context="."
									nodeset="eadheader/child::node()[last()]"
									origin="instance('profiledesc-template')"/>
							</xforms:trigger>
						</xforms:group>
						<xforms:group ref=".[count(//revisiondesc) &lt; 1]">
							<xforms:trigger appearance="minimal">
								<xforms:label>
									<img src="/apps/numishare/images/add.gif"/>Revision
									Description</xforms:label>
								<xforms:insert ev:event="DOMActivate" context="."
									nodeset="eadheader/child::node()[last()]"
									origin="instance('revisiondesc-template')"/>
							</xforms:trigger>
						</xforms:group>
						<div class="section">
							<div>
								<xforms:input ref="eadid">
									<xforms:label>EAD ID</xforms:label>
									<xforms:alert>Required</xforms:alert>
								</xforms:input>
							</div>
							<div>
								<xforms:input ref="eadid/@mainagencycode">
									<xforms:label>Institution Code</xforms:label>
									<xforms:alert>Required</xforms:alert>
								</xforms:input>
							</div>
						</div>
						<div class="section">
							<h2>File Description</h2>							
							<div class="trigger_container">
								<xforms:group ref=".[count(//editionstmt) &lt; 1]">
									<xforms:trigger appearance="minimal">
										<xforms:label>
											<img src="/apps/numishare/images/add.gif"/>Edition
											Statement</xforms:label>
										<xforms:insert ev:event="DOMActivate" context="filedesc"
											origin="instance('editionstmt-template')"/>
									</xforms:trigger>
								</xforms:group>
								<xforms:group ref=".[count(//seriesstmt) &lt; 1]">
									<xforms:trigger appearance="minimal">
										<xforms:label>
											<img src="/apps/numishare/images/add.gif"/>Series
											Statement</xforms:label>
										<xforms:insert ev:event="DOMActivate" context="filedesc"
											origin="instance('seriesstmt-template')"/>
									</xforms:trigger>
								</xforms:group>
							</div>
							<xforms:group ref="filedesc">
								<xforms:group ref="titlestmt">
									<div class="subsection">
										<h3>Title Statement</h3>
										<div class="trigger_container">
											<xforms:group ref=".[count(subtitle) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Subtitle</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('subtitle-template')"/>
												</xforms:trigger>
											</xforms:group>
											<xforms:group ref=".[count(author) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Author</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('author-template')"/>
												</xforms:trigger>
											</xforms:group>
											<xforms:group ref=".[count(sponsor) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Sponsor</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('sponsor-template')"/>
												</xforms:trigger>
											</xforms:group>
										</div>
										<div>
											<xforms:input ref="titleproper">
												<xforms:label>Proper Title</xforms:label>
												<xforms:alert>Required</xforms:alert>
											</xforms:input>
										</div>
										<!-- subtitle -->
										<xi:include href="inputs/subtitle.xml"/>
										<!-- author -->
										<xi:include href="inputs/author.xml"/>
										<!-- sponsor -->
										<xi:include href="inputs/sponsor.xml"/>
									</div>
								</xforms:group>
								<!-- edition stmt -->
								<xforms:group ref="editionstmt">
									<div class="subsection">
										<h3>Edition Statement</h3>
										<div>
											<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Paragraph</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('p-template')"/>
											</xforms:trigger>
										</div>
										<xforms:repeat nodeset=".">
											<div>
												<xforms:input ref="edition">
												<xforms:label>Edition</xforms:label>
												</xforms:input>
											</div>
										</xforms:repeat>
										<!-- paragraph -->
										<xi:include href="inputs/p.xml"/>
									</div>
								</xforms:group>
								<!-- publication statement -->
								<xforms:group ref="publicationstmt">
									<div class="subsection">
										<h3>Publication Statement</h3>
										<div class="trigger_container">
											<xforms:group ref=".[count(address) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Address</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('address-template')"/>
												</xforms:trigger>
											</xforms:group>
											<xforms:group ref=".[count(date) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Date</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('date-template')"/>
												</xforms:trigger>
											</xforms:group>
											<xforms:group ref=".[count(num) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Number</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('num-template')"/>
												</xforms:trigger>
											</xforms:group>
											<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Paragraph</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('p-template')"/>
											</xforms:trigger>
											<xforms:group ref=".[count(publisher) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Publisher</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('publisher-template')"/>
												</xforms:trigger>
											</xforms:group>
										</div>
										<!-- address -->
										<xi:include href="inputs/address.xml"/>
										<!-- date -->
										<xi:include href="inputs/date.xml"/>
										<!-- num -->
										<xi:include href="inputs/num.xml"/>
										<!-- paragraph -->
										<xi:include href="inputs/p.xml"/>
										<!-- publisher -->
										<xi:include href="inputs/publisher.xml"/>
									</div>
								</xforms:group>
								<!-- series statement -->
								<xforms:group ref="seriesstmt">
									<div class="subsection">
										<h3>Series Statement</h3>
										<xforms:trigger appearance="minimal">
											<xforms:delete ev:event="DOMActivate" nodeset="."/>
											<xforms:label>
												<img src="/apps/numishare/images/remove.gif"/>
											</xforms:label>
										</xforms:trigger>

										<div class="trigger_container">
											<xforms:group ref=".[count(num) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Number</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('num-template')"/>
												</xforms:trigger>
											</xforms:group>
											<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Paragraph</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												nodeset="./child::node()[last()]"
												origin="instance('p-template')"/>
											</xforms:trigger>
											<xforms:group ref=".[count(titleproper) &lt; 1]">
												<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Title</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('titleproper-template')"/>
												</xforms:trigger>
											</xforms:group>
										</div>
										<!-- titleproper -->
										<xi:include href="inputs/titleproper.xml"/>
										<!-- num -->
										<xi:include href="inputs/num.xml"/>
										<!-- p -->
										<xi:include href="inputs/p.xml"/>
									</div>
								</xforms:group>
							</xforms:group>
							<!-- profile description -->
							<xforms:group ref="profiledesc">
								<div class="section">
									<h2>Profile Description</h2>
									<xforms:trigger appearance="minimal">
										<xforms:delete ev:event="DOMActivate" nodeset="."/>
										<xforms:label>
											<img src="/apps/numishare/images/remove.gif"/>
										</xforms:label>
									</xforms:trigger>
									<div class="trigger_container">
										<!-- creation, descrules, and langusage are all optional, but may occur no more than once -->
										<xforms:group ref=".[count(creation) &lt; 1]">
											<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Creation</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('creation-template')"/>
											</xforms:trigger>
										</xforms:group>
										<xforms:group ref=".[count(descrules) &lt; 1]">
											<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Descriptive Rules</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('descrules-template')"/>
											</xforms:trigger>
										</xforms:group>
										<xforms:group ref=".[count(langusage) &lt; 1]">
											<xforms:trigger appearance="minimal">
												<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Language Usage</xforms:label>
												<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('langusage-template')"/>
											</xforms:trigger>
										</xforms:group>
									</div>
									<xi:include href="inputs/creation.xml"/>
									<xforms:repeat nodeset="descrules" id="descrules">
										<div>
											<xforms:input ref=".">
												<xforms:label>Descriptive Rules</xforms:label>
											</xforms:input>
											<xforms:trigger appearance="minimal">
												<xforms:delete ev:event="DOMActivate" nodeset="."
												at="index('descrules')"/>
												<xforms:label>
												<img src="/apps/numishare/images/remove.gif"/>
												</xforms:label>
											</xforms:trigger>
										</div>
									</xforms:repeat>
									<xforms:repeat nodeset="langusage" id="langusage">
										<div>
											<xforms:input ref=".">
												<xforms:label>Language Usage</xforms:label>
											</xforms:input>
											<xforms:trigger appearance="minimal">
												<xforms:delete ev:event="DOMActivate" nodeset="."
												at="index('langusage')"/>
												<xforms:label>
												<img src="/apps/numishare/images/remove.gif"/>
												</xforms:label>
											</xforms:trigger>
										</div>
									</xforms:repeat>
								</div>
							</xforms:group>
							<xforms:group ref="revisiondesc">
								<div class="section">
									<h2>Revision Description</h2>
									<xforms:trigger appearance="minimal">
										<xforms:delete ev:event="DOMActivate" nodeset="."/>
										<xforms:label>
											<img src="/apps/numishare/images/remove.gif"/>
										</xforms:label>
									</xforms:trigger>
									<div>
										<xforms:trigger appearance="minimal">
											<xforms:label>
												<img src="/apps/numishare/images/add.gif"
												/>Change</xforms:label>
											<xforms:insert ev:event="DOMActivate" context="."
												origin="instance('change-template')"/>
										</xforms:trigger>
									</div>
									<xforms:repeat nodeset="change" id="change">
										<div class="pair_div">
											<div>
												<xforms:input ref="date">
												<xforms:label>Date</xforms:label>
												</xforms:input>
											</div>
											<div>
												<xforms:input ref="item">
												<xforms:label>Item</xforms:label>
												</xforms:input>
											</div>
											<div style="float:right;">
												<xforms:trigger appearance="minimal">
												<xforms:delete ev:event="DOMActivate" nodeset="."
												at="index('change')"/>
												<xforms:label>
												<img src="/apps/numishare/images/remove.gif"/>
												</xforms:label>
												</xforms:trigger>
											</div>
										</div>
									</xforms:repeat>
								</div>
							</xforms:group>
						</div>
					</xforms:group>
				</widget:tab>
				<!--**************************************** END EAD HEADER **********************************-->
				<!--**************************************** ARCHDESC DESCRIPTIVE IDENTIFICATION **********************************-->
				<widget:tab id="archdesc_did_tab">
					<widget:label>Collection Description</widget:label>
					<h2>Collection Description</h2>
					<p>Fields in this tab record metadata about the numismatic collection.</p>
					<xforms:group ref="instance('archdesc_did')/did">
						<xi:include href="sections/did.xml"/>
					</xforms:group>

				</widget:tab>
				<!--**************************************** END ARCHDESC DESCRIPTIVE IDENTIFICATION **********************************-->
			</widget:tabs>
		</div>
	</body>
</html>
